<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>商品发布 - 供货商管理系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f5f5;
            color: #333;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .page-header {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }

        .page-title {
            font-size: 24px;
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
        }

        .page-desc {
            color: #666;
            font-size: 14px;
        }

        .form-container {
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }

        .form-section {
            margin-bottom: 30px;
        }

        .section-title {
            font-size: 18px;
            font-weight: bold;
            color: #333;
            margin-bottom: 15px;
            padding-bottom: 8px;
            border-bottom: 2px solid #1890ff;
        }

        .form-row {
            display: flex;
            flex-wrap: wrap;
            margin-bottom: 20px;
            gap: 20px;
        }

        .form-group {
            flex: 1;
            min-width: 300px;
        }

        .form-group.full-width {
            flex: 100%;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #333;
        }

        .form-label.required::after {
            content: '*';
            color: #ff4d4f;
            margin-left: 4px;
        }

        .form-input {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #d9d9d9;
            border-radius: 4px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        .form-input:focus {
            outline: none;
            border-color: #1890ff;
            box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
        }

        .form-textarea {
            min-height: 100px;
            resize: vertical;
        }

        .form-select {
            width: 100%;
            padding: 10px 12px;
            border: 1px solid #d9d9d9;
            border-radius: 4px;
            font-size: 14px;
            background-color: white;
        }

        .upload-area {
            border: 2px dashed #d9d9d9;
            border-radius: 4px;
            padding: 40px;
            text-align: center;
            background-color: #fafafa;
            cursor: pointer;
            transition: border-color 0.3s;
        }

        .upload-area:hover {
            border-color: #1890ff;
        }

        .upload-icon {
            font-size: 48px;
            color: #d9d9d9;
            margin-bottom: 10px;
        }

        .upload-text {
            color: #666;
            font-size: 14px;
        }

        .image-preview {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 15px;
        }

        .preview-item {
            position: relative;
            width: 100px;
            height: 100px;
            border: 1px solid #d9d9d9;
            border-radius: 4px;
            overflow: hidden;
        }

        .preview-image {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .preview-remove {
            position: absolute;
            top: 5px;
            right: 5px;
            background: rgba(0,0,0,0.5);
            color: white;
            border: none;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            cursor: pointer;
            font-size: 12px;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            font-size: 14px;
            cursor: pointer;
            transition: all 0.3s;
            margin-right: 10px;
        }

        .btn-primary {
            background-color: #1890ff;
            color: white;
        }

        .btn-primary:hover {
            background-color: #40a9ff;
        }

        .btn-default {
            background-color: #f5f5f5;
            color: #333;
            border: 1px solid #d9d9d9;
        }

        .btn-default:hover {
            background-color: #e6f7ff;
            border-color: #1890ff;
        }

        .btn-success {
            background-color: #52c41a;
            color: white;
        }

        .btn-success:hover {
            background-color: #73d13d;
        }

        .form-actions {
            text-align: center;
            padding-top: 20px;
            border-top: 1px solid #f0f0f0;
        }

        .checkbox-group {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
        }

        .checkbox-item {
            display: flex;
            align-items: center;
        }

        .checkbox-item input[type="checkbox"] {
            margin-right: 8px;
        }

        .price-input {
            position: relative;
        }

        .price-input::before {
            content: '¥';
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: #666;
            z-index: 1;
        }

        .price-input .form-input {
            padding-left: 25px;
        }

        @media (max-width: 768px) {
            .form-group {
                min-width: 100%;
            }
            
            .form-row {
                flex-direction: column;
            }
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="container">
            <!-- 页面标题 -->
            <div class="page-header">
                <h1 class="page-title">商品发布</h1>
                <p class="page-desc">发布新商品到平台，管理商品信息和库存</p>
            </div>

            <!-- 商品发布表单 -->
            <div class="form-container">
                <form @submit.prevent="submitProduct">
                    <!-- 基本信息 -->
                    <div class="form-section">
                        <h3 class="section-title">基本信息</h3>
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label required">商品名称</label>
                                <input type="text" class="form-input" v-model="product.name" placeholder="请输入商品名称" required>
                            </div>
                            <div class="form-group">
                                <label class="form-label required">商品分类</label>
                                <select class="form-select" v-model="product.category" required>
                                    <option value="">请选择分类</option>
                                    <option value="蔬菜">蔬菜</option>
                                    <option value="水果">水果</option>
                                    <option value="肉类">肉类</option>
                                    <option value="海鲜">海鲜</option>
                                    <option value="禽蛋">禽蛋</option>
                                    <option value="粮油">粮油</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label">商品品牌</label>
                                <input type="text" class="form-input" v-model="product.brand" placeholder="请输入品牌名称">
                            </div>
                            <div class="form-group">
                                <label class="form-label">商品规格</label>
                                <input type="text" class="form-input" v-model="product.specification" placeholder="如：500g/袋">
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group full-width">
                                <label class="form-label">商品描述</label>
                                <textarea class="form-input form-textarea" v-model="product.description" placeholder="请详细描述商品特点、产地、品质等信息"></textarea>
                            </div>
                        </div>
                    </div>

                    <!-- 价格库存 -->
                    <div class="form-section">
                        <h3 class="section-title">价格库存</h3>
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label required">销售价格</label>
                                <div class="price-input">
                                    <input type="number" class="form-input" v-model="product.price" placeholder="0.00" step="0.01" min="0" required>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="form-label">市场价格</label>
                                <div class="price-input">
                                    <input type="number" class="form-input" v-model="product.marketPrice" placeholder="0.00" step="0.01" min="0">
                                </div>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label required">库存数量</label>
                                <input type="number" class="form-input" v-model="product.stock" placeholder="请输入库存数量" min="0" required>
                            </div>
                            <div class="form-group">
                                <label class="form-label">库存单位</label>
                                <select class="form-select" v-model="product.unit">
                                    <option value="件">件</option>
                                    <option value="箱">箱</option>
                                    <option value="袋">袋</option>
                                    <option value="斤">斤</option>
                                    <option value="公斤">公斤</option>
                                    <option value="吨">吨</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <!-- 商品图片 -->
                    <div class="form-section">
                        <h3 class="section-title">商品图片</h3>
                        <div class="form-group full-width">
                            <label class="form-label">上传图片</label>
                            <div class="upload-area" @click="triggerFileInput">
                                <div class="upload-icon">📷</div>
                                <div class="upload-text">点击上传商品图片，支持JPG、PNG格式</div>
                                <input type="file" ref="fileInput" @change="handleFileUpload" accept="image/*" multiple style="display: none;">
                            </div>
                            <div class="image-preview" v-if="product.images.length > 0">
                                <div class="preview-item" v-for="(image, index) in product.images" :key="index">
                                    <img :src="image" class="preview-image" alt="商品图片">
                                    <button type="button" class="preview-remove" @click="removeImage(index)">×</button>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 配送信息 -->
                    <div class="form-section">
                        <h3 class="section-title">配送信息</h3>
                        <div class="form-row">
                            <div class="form-group">
                                <label class="form-label">发货地址</label>
                                <input type="text" class="form-input" v-model="product.origin" placeholder="请输入发货地址">
                            </div>
                            <div class="form-group">
                                <label class="form-label">配送方式</label>
                                <div class="checkbox-group">
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="express" v-model="product.deliveryMethods" value="快递">
                                        <label for="express">快递配送</label>
                                    </div>
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="logistics" v-model="product.deliveryMethods" value="物流">
                                        <label for="logistics">物流配送</label>
                                    </div>
                                    <div class="checkbox-item">
                                        <input type="checkbox" id="pickup" v-model="product.deliveryMethods" value="自提">
                                        <label for="pickup">到店自提</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 表单操作 -->
                    <div class="form-actions">
                        <button type="button" class="btn btn-default" @click="saveDraft">保存草稿</button>
                        <button type="button" class="btn btn-primary" @click="previewProduct">预览商品</button>
                        <button type="submit" class="btn btn-success">发布商品</button>
                    </div>
                </form>
            </div>
        </div>
    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const { createApp } = Vue;

        createApp({
            data() {
                return {
                    product: {
                        name: '',
                        category: '',
                        brand: '',
                        specification: '',
                        description: '',
                        price: '',
                        marketPrice: '',
                        stock: '',
                        unit: '件',
                        images: [],
                        origin: '',
                        deliveryMethods: []
                    }
                };
            },
            methods: {
                triggerFileInput() {
                    this.$refs.fileInput.click();
                },
                handleFileUpload(event) {
                    const files = event.target.files;
                    for (let i = 0; i < files.length; i++) {
                        const file = files[i];
                        if (file.type.startsWith('image/')) {
                            const reader = new FileReader();
                            reader.onload = (e) => {
                                this.product.images.push(e.target.result);
                            };
                            reader.readAsDataURL(file);
                        }
                    }
                    event.target.value = '';
                },
                removeImage(index) {
                    this.product.images.splice(index, 1);
                },
                saveDraft() {
                    alert('商品草稿已保存！');
                },
                previewProduct() {
                    if (!this.product.name || !this.product.category || !this.product.price) {
                        alert('请填写商品基本信息后再预览！');
                        return;
                    }
                    alert('商品预览功能开发中...');
                },
                submitProduct() {
                    if (!this.product.name || !this.product.category || !this.product.price || !this.product.stock) {
                        alert('请填写必填信息！');
                        return;
                    }
                    
                    // 模拟提交
                    alert('商品发布成功！');
                    console.log('发布商品:', this.product);
                    
                    // 重置表单
                    this.resetForm();
                },
                resetForm() {
                    this.product = {
                        name: '',
                        category: '',
                        brand: '',
                        specification: '',
                        description: '',
                        price: '',
                        marketPrice: '',
                        stock: '',
                        unit: '件',
                        images: [],
                        origin: '',
                        deliveryMethods: []
                    };
                }
            }
        }).mount('#app');
    </script>
</body>
</html>